
package com.boot.springBoot.util;

import org.apache.commons.lang3.StringUtils;

/**
 * 
 * 
 * @author Administrator
 *
 */
public class StringUtil {
	

	private static String json ="{'trans_id':'1','trans_no':[],'succ_amt':[],'biz_type':'0000','trade_date':'20180515201746','trans_serial_no':'TISN1526386666891','member_id':'1157261','terminal_id':'34301','resp_code':'00232','resp_msg':'银行卡未开通银联无卡支付','data_type':'xml','txn_sub_type':'13','req_reserved':'保留','additional_info':'附加信息','txn_type':'0431','version':'4.0.0.0'}";
	
	public  static void getString() {
		int start = json.lastIndexOf("resp_msg")+9;
		System.out.println("length=="+json.length());
		System.out.println("start=="+start);
		int end = json.lastIndexOf(", terminal_id");
		if(end == -1){
			end = start + 20;
		}
		System.out.println("end=="+end);
		String msg = json.substring(start, end);
		System.out.println("msg=="+msg);
		
	}
	
	
	public static void main(String[] args) {
//		getString();
		System.out.println(StringUtils.substringBefore(json,"0000"));
		System.out.println(StringUtils.substringAfterLast(json,":").replace("}",""));
	}
}
